<html>
<head><meta charset="utf-8"><title>check if a string is a valid ident? · t-compiler · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/index.html">t-compiler</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/check.20if.20a.20string.20is.20a.20valid.20ident.3F.html">check if a string is a valid ident?</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="212062019"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/check%20if%20a%20string%20is%20a%20valid%20ident%3F/near/212062019" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> GuillaumeGomez <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/check.20if.20a.20string.20is.20a.20valid.20ident.3F.html#212062019">(Oct 02 2020 at 11:29)</a>:</h4>
<p>I tried to check if there was a method accepting a <code>&amp;str</code> that would allow me to check if it is a valid ident (or converting it to an ident and then I'd check if I get <code>Some(...)</code>) but couldn't find anything except from the parser directly. Is there any such method/function?</p>



<a name="212103892"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/check%20if%20a%20string%20is%20a%20valid%20ident%3F/near/212103892" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/check.20if.20a.20string.20is.20a.20valid.20ident.3F.html#212103892">(Oct 02 2020 at 17:24)</a>:</h4>
<p>Does this help: <a href="https://doc.rust-lang.org/nightly/nightly-rustc/rustc_lexer/fn.is_ident.html"><code>rustc_lexer::is_ident</code></a>?</p>



<a name="212103929"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/check%20if%20a%20string%20is%20a%20valid%20ident%3F/near/212103929" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/check.20if.20a.20string.20is.20a.20valid.20ident.3F.html#212103929">(Oct 02 2020 at 17:24)</a>:</h4>
<p>It's a static method</p>



<a name="212127873"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/check%20if%20a%20string%20is%20a%20valid%20ident%3F/near/212127873" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> GuillaumeGomez <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/check.20if.20a.20string.20is.20a.20valid.20ident.3F.html#212127873">(Oct 02 2020 at 20:55)</a>:</h4>
<p>Yes, it's exactly what I was looking for! Thanks!</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>